package com.corona.game;

import com.badlogic.gdx.graphics.g2d.Sprite;
import com.corona.Game;

import java.util.ArrayList;

/* compiled from: Action.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/DrawControls.class */
class DrawControls extends Action {
    public boolean remove = false;
    boolean displayControls = true;
    int timer = 0;
    int timerPadding = 240;
    float alpha = 1.0f;
    String currTrainerTip = "";
    int prevIndex = -1;
    ArrayList<String> messages = new ArrayList<>(TrainerTipsTile.messages);
    int randomIndex;

    public DrawControls() {
        super(new Object[0]);
        this.randomIndex = 0;
        this.randomIndex = Game.rand.nextInt(this.messages.size());
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public void firstStep(Game game) {
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        PkmnMap.PeriodicSave.resetTimer();
        if (this.remove) {
            game.actionStack.remove(this);
        }
        game.otherFlipY = true;
        if (this.timer <= 60) {
            if (this.timer % 10 == 0) {
                this.alpha = ((float) this.timer) / 60.0f;
            }
        } else if (this.timer >= 300 + this.timerPadding) {
            if (this.timer % 10 == 0) {
                this.alpha = 1.0f - (((float) (this.timer % 60)) / 60.0f);
            }
        } else if (InputProcessor.aJustPressed) {
            this.timer = 300 + this.timerPadding;
        }
        int i = this.timer + 1;
        this.timer = i;
        if (i >= 360 + this.timerPadding) {
            this.timer = 0;
            this.displayControls = false;
            this.timerPadding = 60;
            this.randomIndex++;
            if (this.randomIndex >= this.messages.size()) {
                this.randomIndex = 0;
            }
            this.currTrainerTip = "   TRAINER TIPS!  " + this.messages.get(this.randomIndex);
            for (int tries = 0; tries < 4 && (this.randomIndex == this.prevIndex || this.currTrainerTip.length() > 105); tries++) {
                this.randomIndex++;
                if (this.randomIndex >= this.messages.size()) {
                    this.randomIndex = 0;
                }
                this.currTrainerTip = "   TRAINER TIPS!  " + this.messages.get(this.randomIndex);
            }
            this.prevIndex = this.randomIndex;
        }
        if (!this.displayControls) {
            char[] textArray = this.currTrainerTip.toCharArray();
            int i2 = 0;
            int j = 0;
            int k = 0;
            while (k < textArray.length) {
                char character = textArray[k];
                if (character == ' ' && k + 1 < textArray.length) {
                    int length = 1;
                    for (char nextChar = textArray[k + 1]; nextChar != ' ' && k + length < textArray.length; nextChar = textArray[k + length]) {
                        length++;
                    }
                    if (i2 + length > 20) {
                        i2 = 0;
                        j++;
                    }
                }
                Sprite letterSprite = game.transparentDict.get(Character.valueOf(character));
                letterSprite.setPosition((float) (8 * i2), (float) (128 - (16 * j)));
                letterSprite.draw(game.uiBatch, this.alpha);
                i2++;
                if (i2 > 20) {
                    i2 = 0;
                    j++;
                }
                k++;
            }
            return;
        }
        for (int j2 = 0; j2 < 8; j2++) {
            if (j2 == 0) {
                char[] textArray2 = "   - Controls -".toCharArray();
                for (int i3 = 0; i3 < textArray2.length; i3++) {
                    Sprite letterSprite2 = game.transparentDict.get(Character.valueOf(textArray2[i3]));
                    letterSprite2.setPosition((float) (8 + (8 * i3)), (float) (128 - (16 * j2)));
                    letterSprite2.draw(game.uiBatch, this.alpha);
                }
            } else if (j2 == 1) {
                char[] textArray3 = "Arrows  - Movement".toCharArray();
                for (int i4 = 0; i4 < textArray3.length; i4++) {
                    Sprite letterSprite3 = game.transparentDict.get(Character.valueOf(textArray3[i4]));
                    letterSprite3.setPosition((float) (8 + (8 * i4)), (float) (128 - (16 * j2)));
                    letterSprite3.draw(game.uiBatch, this.alpha);
                }
            } else if (j2 == 2) {
                char[] textArray4 = "Z       - A button".toCharArray();
                for (int i5 = 0; i5 < textArray4.length; i5++) {
                    Sprite letterSprite4 = game.transparentDict.get(Character.valueOf(textArray4[i5]));
                    letterSprite4.setPosition((float) (8 + (8 * i5)), (float) (128 - (16 * j2)));
                    letterSprite4.draw(game.uiBatch, this.alpha);
                }
            } else if (j2 == 3) {
                char[] textArray5 = "X       - B button".toCharArray();
                for (int i6 = 0; i6 < textArray5.length; i6++) {
                    Sprite letterSprite5 = game.transparentDict.get(Character.valueOf(textArray5[i6]));
                    letterSprite5.setPosition((float) (8 + (8 * i6)), (float) (128 - (16 * j2)));
                    letterSprite5.draw(game.uiBatch, this.alpha);
                }
            } else if (j2 == 4) {
                char[] textArray6 = "Enter   - Menu".toCharArray();
                for (int i7 = 0; i7 < textArray6.length; i7++) {
                    Sprite letterSprite6 = game.transparentDict.get(Character.valueOf(textArray6[i7]));
                    letterSprite6.setPosition((float) (8 + (8 * i7)), (float) (128 - (16 * j2)));
                    letterSprite6.draw(game.uiBatch, this.alpha);
                }
            } else if (j2 == 5) {
                char[] textArray7 = "Hold X to run".toCharArray();
                for (int i8 = 0; i8 < textArray7.length; i8++) {
                    Sprite letterSprite7 = game.transparentDict.get(Character.valueOf(textArray7[i8]));
                    letterSprite7.setPosition((float) (8 + (8 * i8)), (float) (128 - (16 * j2)));
                    letterSprite7.draw(game.uiBatch, this.alpha);
                }
            }
        }
    }
}
